#include "carsystem.h"

#include <QApplication>
#include <QLabel>
#include <QMovie>
#include <QSplashScreen>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QPixmap pixmap(":/background-image/v.png"); //绑定一个图片
    QSplashScreen *splash=new QSplashScreen;
    splash->setPixmap(pixmap);
    splash->show(); //显示启动画面

    splash->showMessage("Version:1.0\nCopyright(c)2020 Towel Roll", Qt::AlignHCenter|Qt::AlignBottom, Qt::white);//版本，版权信息

    //显示动画(gif图片)
    QLabel *label = new QLabel(splash);
    QMovie *movie = new QMovie(":/background-image/car.gif");

    label->setMovie(movie);
    movie->start();

    label->setGeometry(300,200,200,156);
    label->show();

    QDateTime n=QDateTime::currentDateTime();
    QDateTime now;
    do{
        now=QDateTime::currentDateTime();
        a.processEvents();
    } while (n.secsTo(now)<=5);//5为需要延时的秒数

    CarSystem w;
    w.show();

    splash->finish(&w); //当主窗口启动后，启动画面隐藏
    delete splash;

    return a.exec();
}
